/*
 * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2019. All rights reserved.
 * Description: video analysis adas interface
 * Author: HiMobileCam Reference Develop Team
 * Create: 2019-11-01
 */

#ifndef HI_VIDEOANALYSIS_ADAS_H
#define HI_VIDEOANALYSIS_ADAS_H

#include "hi_aiservice_adas.h"
#include "hi_appcomm.h"
#include "hi_videoprocess.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */

/* invalid argument error code */
#define HI_VIDEOANALYSIS_ADAS_EINVAL       HI_APPCOMM_ERR_ID(HI_APP_MOD_VIDEOANALYSIS_ADAS, HI_EINVAL)
/* no initialized error code */
#define HI_VIDEOANALYSIS_ADAS_ENOINIT      HI_APPCOMM_ERR_ID(HI_APP_MOD_VIDEOANALYSIS_ADAS, HI_ENOINIT)

#define HI_VIDEOANALYSIS_ADAS_TASK_NUM_MAX  3

typedef enum {
    HI_EVENT_VIDEOANALYSIS_ADAS_CALIBRATION = HI_APPCOMM_EVENT_ID(HI_APP_MOD_VIDEOANALYSIS_ADAS, 0),
    HI_EVENT_VIDEOANALYSIS_ADAS_RESULT_PER_IMAGE,
    HI_EVENT_VIDEOANALYSIS_ADAS_ERROR,
    HI_EVENT_VIDEOANALYSIS_ADAS_BUTT
} HI_VIDEOANALYSIS_AdasEvent;

typedef enum {
    HI_VIDEOANALYSIS_ADAS_CMD_SET_SPEED = 0,
    HI_VIDEOANALYSIS_ADAS_CMD_SET_DAY_NIGHT,
    HI_VIDEOANALYSIS_ADAS_CMD_BUTT
} HI_VIDEOANALYSIS_AdasCmd;

typedef struct {
    HI_S32 frameRate;
    const HI_CHAR *modelPath;
    HiAdasCapabilityMask capMask;
    HiAdasCalibrateAttr caliAttr;
    HI_CHAR algoName[HI_ADAS_MAX_NAME_LEN];
    HI_VIDEOPROCESS_YuvSrc yuvSrc;
} HI_VIDEOANALYSIS_AdasVideoProcessTaskCfg;

typedef struct {
    HiAdasAlgoProcessResult result;
    HI_U32 width;
    HI_U32 height;
} HI_VIDEOANALYSIS_AdasResult;

typedef HI_S32 (*HI_VIDEOANALYSIS_AdasTaskResultProcCb)(HI_VIDEOANALYSIS_AdasResult *result, HI_VOID *privData);

HI_S32 HI_VIDEOANALYSIS_InitAdasService(HI_VOID);

HI_S32 HI_VIDEOANALYSIS_RegisteAdasAlg(const HiAdasAlgorithm *algorithm);

HI_S32 HI_VIDEOANALYSIS_UnregisteAdasAlg(const HI_CHAR *adasAlgoName);

HI_S32 HI_VIDEOANALYSIS_GetAdasAlgCapability(const HI_CHAR *adasAlgoName, HiAdasCapability *capability);

HI_S32 HI_VIDEOANALYSIS_CreateAdasTask(HI_HANDLE *adasTaskHdl,
    const HI_VIDEOANALYSIS_AdasVideoProcessTaskCfg *adasVideoProcessTaskCfg,
    HI_VIDEOANALYSIS_AdasTaskResultProcCb resultCb);

HI_S32 HI_VIDEOANALYSIS_DestroyAdasTask(HI_HANDLE adasTaskHdl);

HI_S32 HI_VIDEOANALYSIS_StartAdasTask(HI_HANDLE adasTaskHdl);

HI_S32 HI_VIDEOANALYSIS_StopAdasTask(HI_HANDLE adasTaskHdl);

HI_S32 HI_VIDEOANALYSIS_SetAdasTaskAttr(HI_HANDLE adasTaskHdl, HiAdasAttrType type, const HiAdasAttr* attr);

HI_S32 HI_VIDEOANALYSIS_GetAdasTaskAttr(HI_HANDLE adasTaskHdl, HiAdasAttrType type, HiAdasAttr* attr);

HI_S32 HI_VIDEOANALYSIS_InvokeAdasTaskCmd(HI_HANDLE adasTaskHdl, HI_U32 cmd, const HiAdasCmdPara* cmdPara);

HI_S32 HI_VIDEOANALYSIS_DeinitAdasService(HI_VOID);

HI_S32 HI_VIDEOANALYSIS_RegisterEvent(HI_VOID);

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */

#endif /* HI_VIDEOANALYSIS_ADAS_H */
